<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        ul{
            width: 100px;
            height: 200px;
            float: left;
            border: 1px solid gold;
            text-align: center;
        }
        ul li{
            width: 100px;
            height: 40px;
            line-height: 40px;
            cursor: pointer;
        }
        div{
            width: 200px;
            height: 200px;
            border: 1px solid hotpink;
            float: left;
            margin-left: 20px;
            text-align: center;
            line-height: 200px;
        }
        .on{
            background: #ccc;
        }
    </style>
</head>
<body>
    <ul>
        <li class="on">1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
    </ul>
    <div>1</div>
</body>
<script>
    var arr = [
        {title:"1",content:"a"},
        {title:"2",content:"b"},
        {title:"3",content:"c"},
        {title:"4",content:"d"},
        {title:"5",content:"e"}
    ];
    //渲染选项卡
    var ul = document.querySelector('ul');
    var div = document.querySelector('div');
    ul.innerHTML = arr.map(function(item,index)
    {
        return `<li ${index == 0 ? 'class="on"' : ''}>${item.title}</li>`;
    }).join("");
    div.innerHTML = arr[0].content;
    ul.onclick = function(e)
    {
        var t = e.target;
        // console.log(t);
        if(t.tagName=='LI')
        {
            //切换高亮
            //找
            var pn = ul.querySelector('.on');
            //删
            pn && pn.classList.remove("on");
            //加
            t.classList.add("on");
            //切换内容
            var index = [...ul.children].indexOf(t);
            div.innerHTML = arr[index].content;
        }
    }
</script>
</html>